package com.s63.modules.rabbit;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {
    public static final String NAME_QUEUE_USER_CREATED = "s63.queue.user.created";
    public static final String NAME_EXCHANGE_DIRECT = "s63.exchange.direct";
    public static final String NAME_ROUTING_KEY_USER_ADD = "routing.key.user.add";
    @Bean
    public Queue queue() {
        return new Queue(NAME_QUEUE_USER_CREATED);
    }

    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange(NAME_EXCHANGE_DIRECT);
    }

    @Bean
    public Binding binding() {
        return BindingBuilder.bind(queue()).to(directExchange()).with(NAME_ROUTING_KEY_USER_ADD);
    }
}
